package com.company.service.Impl;

import com.company.mapper.UserMapper;
import com.company.pojo.User;
import com.company.service.UserService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author
 * @date 2021-07-26 11:48
 */
@Service
public class UserServiceImpl implements UserService {

    private UserMapper userMapper;


    @Autowired
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public boolean save(User user) {
       return userMapper.save(user);
    }

    @Override
    public boolean update(User user) {

        return userMapper.update(user);
    }

    @Override
    public boolean delete(Integer uuid) {
        return userMapper.delete(uuid);
    }

    @Override
    public User get(Integer uuid) {
        return userMapper.get(uuid);
    }

    @Override
    public PageInfo<User> getAll(int page, int size) {
        PageHelper.startPage(page, size);
        List<User> users = userMapper.listAll();
        return new PageInfo<>(users);
    }

    @Override
    public User login(String userName, String password) {
       return userMapper.getByUserNameAndPassword(userName, password);
    }
}
